package com.four.project.controller;

import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 这是异常拦截类
 * @Description
 * @Author 梯子君(xie)
 * @Data 2020/7/812:06
 */
@ControllerAdvice
@ResponseBody
@CrossOrigin
public class ExceptionController {

    @ExceptionHandler(value = UnauthorizedException.class)//无权限
    public String exce(){
        return "您没有该权限";
    }

    @ExceptionHandler(value = AuthorizationException.class)//未登录
    public String unlogin(){
        return "您没有登录,请返回首页登录";
    }

}
